package com.example.demo.service;

import com.example.demo.entity.User;
import com.example.demo.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;

@Service
public class UserService {
    @Autowired
    UserRepository userRepository;
    public boolean login(User user) {
        String password = DigestUtils.md5DigestAsHex(user.getPassword().getBytes());
        var res=userRepository.findByUsernameAndPassword(user.getUsername(),password);
        return res.isPresent();
    }
}
